﻿//using IFix;
//using IFix.Core;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Reflection;
using UnityEngine;

public class ReporterShow : MonoBehaviour {

    public Reporter reporter;
    
    private void Start()
    {
        DontDestroyOnLoad(this);

        //System.Type[] types = Assembly.Load("Assembly-CSharp").GetTypes();
        //int index = 0;
        //for (int i = 0; i < types.Length; i++)
        //{
        //    //Debug.Log("types[i].Namespace:" + types[i].Namespace + "&");
        //    if (string.IsNullOrEmpty(types[i].Namespace) && !types[i].Name.Contains("<"))
        //    {
        //        index++;
        //        Debug.Log("<color=red>Name/FullName" + index + ":</color> " + types[i].Name + "/" + types[i].FullName);
        //    }
        //}


        //System.Type[] fpTypes = Assembly.Load("Assembly-CSharp-firstpass").GetTypes();
        //int index2 = 0;
        //for (int i = 0; i < fpTypes.Length; i++)
        //{
        //    //Debug.Log("types[i].Namespace:" + types[i].Namespace + "&");
        //    if (string.IsNullOrEmpty(fpTypes[i].Namespace) && !fpTypes[i].Name.Contains("<"))
        //    {
        //        index2++;
        //        Debug.Log("<color=yellow>Name/FullName" + index2 + ":</color> " + fpTypes[i].Name + "/" + fpTypes[i].FullName);
        //    }
        //}

        //VirtualMachine.Info = (s) => UnityEngine.Debug.Log(s);
        ////try to load patch for Assembly-CSharp.dll
        //var patch = Resources.Load<TextAsset>("Assembly-CSharp.patch");
        //if (patch != null)
        //{
        //    UnityEngine.Debug.Log("loading Assembly-CSharp.patch ...");
        //    var sw = Stopwatch.StartNew();
        //    PatchManager.Load(new MemoryStream(patch.bytes));
        //    UnityEngine.Debug.Log("patch Assembly-CSharp.patch, using " + sw.ElapsedMilliseconds + " ms");
        //}
        ////try to load patch for Assembly-CSharp-firstpass.dll
        //patch = Resources.Load<TextAsset>("Assembly-CSharp-firstpass.patch");
        //if (patch != null)
        //{
        //    UnityEngine.Debug.Log("loading Assembly-CSharp-firstpass ...");
        //    var sw = Stopwatch.StartNew();
        //    PatchManager.Load(new MemoryStream(patch.bytes));
        //    UnityEngine.Debug.Log("patch Assembly-CSharp-firstpass, using " + sw.ElapsedMilliseconds + " ms");
        //}

        //UnityEngine.Debug.Log("<color=red>10 + 9 = " + ReporterShow.Add(10, 9) + "</color>");
    }

    void OnGUI()
    {
#if VERSION_BANSHU
        //return;
#endif
        if (reporter != null)
        {
            GUI.color = new Color(1, 1, 1, 0.4f);
            if (GUI.Button(new Rect(Screen.width / 2 - 120, 0, 60, 60), "  "))
            {
                reporter.OnClick();
            }
        }
        else
        {
            reporter = new Reporter();
        }

        //GUI.color = new Color(1, 1, 1, 0.4f);
        //if (GUI.Button(new Rect(Screen.width / 2 , 0, 60, 60), "  "))
        //{
        //    FightSys.Instance.endFightRoomTemp();
        //}
    }
    
    public static int Add(int a, int b)
    {
        return a * b;
    }

    public int Sub(int a, int b)
    {
        return a - b;
    }
}
